package models;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import play.db.jpa.Model;

/**
 * Class for table T_POST.
 * 
 * JUST TO TEST !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 * 
 * @author Elisa
 */
@Entity
@Table(name = "T_POST")
public class Post extends Model {

	// don't prefix by "this." because of the column name in database
	private String title;
	private Date postedAt;
	@Lob // large text database type to store the post content
	private String content;
	@ManyToOne // That means that each Post is authored by a single User, and that each User can author several Posts
	private User poster;
	
	/**
	 * Constructor.
	 * @param poster the user who post the comment
	 * @param title title of the comment
	 * @param content content of the comment
	 */
	public Post(User poster, String title, String content) {
		this.poster = poster;
		this.title = title;
		this.content = content;
		this.postedAt = new Date();
	}


	// ========================= getters/setters
	
	/**
	 * Get the title property.
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}


	/**
	 * Set the title.
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}


	/**
	 * Get the postedAt property.
	 * @return the postedAt
	 */
	public Date getPostedAt() {
		return postedAt;
	}


	/**
	 * Set the postedAt.
	 * @param postedAt the postedAt to set
	 */
	public void setPostedAt(Date postedAt) {
		this.postedAt = postedAt;
	}


	/**
	 * Get the content property.
	 * @return the content
	 */
	public String getContent() {
		return content;
	}


	/**
	 * Set the content.
	 * @param content the content to set
	 */
	public void setContent(String content) {
		this.content = content;
	}


	/**
	 * Get the poster property.
	 * @return the poster
	 */
	public User getPoster() {
		return poster;
	}


	/**
	 * Set the poster.
	 * @param poster the poster to set
	 */
	public void setPoster(User poster) {
		this.poster = poster;
	}

}
